<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/static/js/dev.js"></script>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>
    <title>站内信主体表单</title>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <!--按钮栏-->
            <div class="form-group button-bar button-bar">
                <button type="button" isShow="joForm.isAdd" class="btn btn-primary" onclick="joForm.save()">
                    <i class="fa fa-plus-circle" aria-hidden="true"></i>&nbsp;新增
                </button>
                <button type="button" isShow="!joForm.isAdd" class="btn btn-info" onclick="joForm.update()">
                    <i class="fa fa-pencil-square" aria-hidden="true"></i>&nbsp;修改
                </button>
                <button type="button" isShow="!joForm.isAdd" class="btn btn-danger" onclick="joForm.del()">
                    <i class="fa fa-trash" aria-hidden="true"></i>&nbsp;删除
                </button>
            </div>
            <!--按钮栏-->
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <form id="pageForm" name="pageForm" action="" method="post">
                <div class="young-form-item col-md-12 must">
                    <div class="young-form-label">标题</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <input type="text"   name="title" value="" class="form-control "  ErrEmpty="标题不允许为空" />
                    </div>
                </div>
                <div class="young-form-item col-md-12 must">
                    <div class="young-form-label">内容</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <textarea  name="content" value="" class="form-control "  ErrEmpty="内容不允许为空" rows="5" ></textarea>
                    </div>
                </div>

                <div class="young-form-item col-md-6 must">
                    <div class="young-form-label">发件人类型</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <select id="senderType" name="senderType" class="form-control" onchange="onchangeShowControl('senderType', 10, 'senderType-10-hide')" ErrNumber="发件人类型需填写数字类型">
                            <option value=""></option>
                            <option value="10">系统</option>
                            <option value="20">用户</option>
                        </select>
                    </div>
                </div>
                <div class="young-form-item col-md-6 senderType-10-hide">
                    <div class="young-form-label">发件人ID</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <input type="text"   name="sender" value="" class="form-control "   />
                    </div>
                </div>
                <div class="young-form-item col-md-6 ">
                    <div class="young-form-label">发件人名称</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <input type="text"   name="senderName" value="" class="form-control "   />
                    </div>
                </div>


                <div class="young-form-item col-md-6 must">
                    <div class="young-form-label">收信人类型</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <select id="receiverType" name="receiverType" class="form-control" onchange="onchangeShowControl('receiverType', 20, 'receiverType-20-hide')" ErrNumber="收信人类型需填写数字类型">
                            <option value=""></option>
                            <option value="10">单用户</option>
                            <option value="20">全体用户</option>
                        </select>
                    </div>
                </div>
                <div class="young-form-item col-md-6 receiverType-20-hide">
                    <div class="young-form-label">收信人ID</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <input type="text"   name="receiver" value="" class="form-control "   />
                    </div>
                </div>

                <div class="young-form-item col-md-6 must">
                    <div class="young-form-label">信件状态</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <select name="state" class="form-control"  ErrNumber="状态需填写数字类型">
                            <option value=""></option>
                            <option value="10">暂存</option>
                            <option value="20">已发送</option>
                        </select>
                    </div>
                </div>
                <div class="young-form-item col-md-6 ">
                    <div class="young-form-label">发送时间</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <input type="text" id="sendTime" value="" name="sendTime" class="form-control" readonly   />
                    </div>
                </div>
                <div class="young-form-item col-md-6 ">
                    <div class="young-form-label">业务标记</div>
                    <div class="young-form-tips"></div>
                    <div class="young-form-input-block">
                        <input type="text"   name="businessTag" value="" class="form-control "   />
                    </div>
                </div>


            </form>
        </div>
    </div>
</div>

<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<script type="text/javascript">

    $(function(){
        var jParams = {
            "PKName" : "id",//主键属性名
            "saveAfter" : "toEdit",
            "addUrl" : "/msg/siteLetter/insert",//新增
            "deleteUrl" : "/msg/siteLetter/delete",//删除
            "updateUrl" : "/msg/siteLetter/update",//修改
            "formDataUrl" : "/msg/siteLetter/get",//查询
            //"readonly2Label" : true //只读转文本
        };
        joForm.initFormPage(jParams);//初始化
    });
    //初始化新增页面回调函数(在初始化按钮前发生)
    joForm.initFormPageOfAdd = function(){
        onchangeShowControl('senderType', 10, 'senderType-10-hide');
        onchangeShowControl('receiverType', 20, 'receiverType-20-hide');
    };
    //初始化表单值前处理
    joForm.initFormValueBefore = function(oJson){
        oJson.sendTime = jo.formatDate(oJson.sendTime);
    };
    //初始化表单值后处理
    joForm.initFormValueAfter = function(oJson){
        onchangeShowControl('senderType', 10, 'senderType-10-hide');
        onchangeShowControl('receiverType', 20, 'receiverType-20-hide');
    };
    //新增请求提交前回调函数
    joForm.dealDataAtSaveBefore = function(oJson){

    };
    //修改请求提交前回调函数
    joForm.dealDataAtUpdateBefore = function(oJson){

    };
    /* 关于joForm更多回调函数和配置参数可查看jo-page-form.js */


    /**
     * 输入变更展示控制
     * @param eleId 元素id,比如select的id
     * @param hideVal 当值等于此值时触发隐藏
     * @param hideEleClass 被隐藏元素的class
     */
    function onchangeShowControl(eleId, hideVal, hideEleClass) {
        var val = $('#' + eleId).val();
        if (val == hideVal) {
            $('.' + hideEleClass).hide();
        } else {
            $('.' + hideEleClass).show();
        }
    }

</script>
</body>
</html>
